// source --> https://shopfilingsuperstore.com/wp-content/plugins/conner-product-filter/assets/js/product-filter.js?ver=5.5.8 var cpf_product_filter; jQuery(function ($) { cpf_product_filter = { datatable : null, types_default : '', features_default : '', colors_default : '', tables : {}, categories : {}, category_map : [], init : function() { var that = this; that.types_default = $('.filter-type').html(); that.features_default = $('.filter-feature').html(); that.colors_default = $('.filter-color').html(); $('.btn-stock-filter').on('click', function() { if( ! $(this).is('.selected')) { $('.btn-stock-filter').removeClass('selected'); $(this).addClass('selected'); } $('.btn-filter').trigger('click'); }); $('.selected-filter-wrapper').on('click', '.btn-clear-filter', function() { $('.selected-filter-wrapper').html(''); $('.filter-category').val(''); $('.filter-type').val(''); $('.filter-feature').val(''); $('.filter-color').val(''); $('.filter-type') .addClass('no-selection') .html(that.types_default); $('.filter-feature') .addClass('no-selection') .html(that.features_default); $('.filter-color') .addClass('no-selection') .html(that.colors_default); $('.btn-filter').trigger('click'); }); $('.btn-filter').on('click', function() { that.filter_change_grouped(); }); $('#product-list').on('click', '.btn-add-cart', function() { that.add_to_cart(this); }); $('.filter-category').on('change', function() { that.load_types($(this).val()); }); $('.filter-type').on('change', function() { that.load_features($(this).val()); that.load_colors(); }); $('.filter-feature').on('change', function() { that.load_colors(); }); $('#product-list').on('click', '.category-header', function(e) { if($(this).hasClass('_collapsed')) { $(this).removeClass('_collapsed'); } else { $(this).addClass('_collapsed'); } }); let urlSearchParams = new URLSearchParams(window.location.search); let product_category = urlSearchParams.get('product_category'); let product_type = urlSearchParams.get('product_type'); let product_feature = urlSearchParams.get('product_feature'); that.initialize_category_map().then(()=>{ if (product_category){ that.update_filter_fields(); $('select.filter-category').val(product_category); that.load_types(product_category).then(()=>{ if (product_type){ $('select.filter-type').val(product_type); return that.load_features(product_type) } }).then(()=>{ if (product_feature){ $('select.filter-feature').val(product_feature); return that.load_colors(); } }).then(that.filter_change_grouped); } else { that.datatable = $('.product-list-table').DataTable({ ajax : { url : cpf_data.ajaxurl + '?action=cpf_get_products', data : function( d ) { d.filter_stock_status = $('.btn-stock-filter.selected').data('status'); } }, processing : true, serverSide : true, responsive: true, columns : [ { data : "name_grouped", render : function( data ) { var html = ''; html += '' + data.name + ''; html += '
' + data.excerpt + '
'; return html; } }, { data : "color", orderable : false}, { data : "price", render: { _:'display', sort:'numeric' } }, { data : "quantity", orderable : false}, { data : "ID", orderable : false, render : function(data, type, row, meta ) { return ''; } } ], order : [[ 2, "asc" ]], bLengthChange : false, bFilter : false }); that.update_filter_fields(); } }); }, initialize_category_map: function(){ var request = { action:'cpf_load_product_category_map' }; return new Promise((resolve)=>{ $.post(cpf_data.ajaxurl, request, function(response) { cpf_product_filter.category_map = response; resolve(); }); }); }, initialize_single_table: function(selector){ var category = $(selector).data('category'); var type = $(selector).data('type'); var feature = $(selector).data('feature'); var color = $(selector).data('color'); var id = $(selector).data('id'); $(selector).removeClass('init'); cpf_product_filter.tables[id] = {}; cpf_product_filter.tables[id].category = category; cpf_product_filter.tables[id].type = type; cpf_product_filter.tables[id].feature = feature; cpf_product_filter.tables[id].color = color; cpf_product_filter.tables[id].table = $(selector).DataTable({ ajax : { url : cpf_data.ajaxurl + '?action=cpf_get_products', data : function( d ) { d.filter_stock_status = $('.btn-stock-filter.selected').data('status'); if(cpf_product_filter.tables[id].category) { d.filter_category = cpf_product_filter.tables[id].category; } if(cpf_product_filter.tables[id].type) { d.filter_type = cpf_product_filter.tables[id].type; } if(cpf_product_filter.tables[id].feature) { d.filter_feature = cpf_product_filter.tables[id].feature; } if(cpf_product_filter.tables[id].color) { d.filter_color = cpf_product_filter.tables[id].color; } } }, processing : true, serverSide : true, responsive: true, columns : [ { data : "name_grouped", render : function( data ) { var html = ''; html += '' + data.name + ''; html += '' + data.excerpt + '
'; return html; } }, { data : "color", orderable : false}, { data : "price", render: { _:'display', sort:'numeric' } }, { data : "quantity", orderable : false}, { data : "ID", orderable : false, render : function(data, type, row, meta ) { return ''; } } ], order : [[ 2, "asc" ]], bLengthChange : false, bFilter : false }); }, initialize_table : function() { $('.product-list-table.init').each(function() { cpf_product_filter.initialize_single_table(this); }); }, add_to_cart : function(obj) { var request = { action : 'cpf_ajax_add_cart', ID : $(obj).data('id'), quantity : $(obj).closest('tr').find('[name=quantity]').val() }; $(obj).prop('disabled', true).text('Please Wait...'); $(obj).closest('td').find('p').remove(); $.post(cpf_data.ajaxurl, request, function(response) { $(obj).prop('disabled', false).text('Add to Cart'); $(obj).after('Added to Cart View Cart'); if (typeof response['cart_contents_count'] !== 'undefined' && response['cart_contents_count'] > 0){ $('#menu-top-bar').find('.menu-item a').each(function(){ if ($(this).text().toLowerCase().indexOf('my cart') !== -1){ $(this).text('My Cart ('+response['cart_contents_count']+')'); } }); } setTimeout(function() { $(obj).closest('td').find('p').remove(); }, 5000); }); }, filter_change : function() { var html = ''; if($('.filter-category').val()) { var selected_text = $('.filter-category option:selected').text(); html += '
'; if($('.filter-type').val()) { var selected_text = $('.filter-type option:selected').text(); html += ''; if($('.filter-feature').val()) { var selected_text = $('.filter-feature option:selected').text(); html += ''; } } html += 'Name | '; html += 'Color | '; html += 'Price | '; html += 'Quantity | '; html += 'Add | '; html += '
---|
'
+(escaped?code:escape(code,true))
+'\n
';}
return''
+(escaped?code:escape(code,true))
+'\n
\n';};Renderer.prototype.blockquote=function(quote){return'\n'+quote+'\n';};Renderer.prototype.html=function(html){return html;};Renderer.prototype.heading=function(text,level,raw){return'
'+text+'
\n';};Renderer.prototype.table=function(header,body){return''+text+'
';};Renderer.prototype.br=function(){return this.options.xhtml?'' +escape(e.message+'',true) +'';} throw e;}} marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked;};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:'lang-',smartypants:false,headerPrefix:'',renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=='undefined'&&typeof exports==='object'){module.exports=marked;}else if(typeof define==='function'&&define.amd){define(function(){return marked;});}else{this.marked=marked;}}).call(function(){return this||(typeof window!=='undefined'?window:global);}());;(function(jQuery){jQuery.fn.serializeObject=function(options){options=jQuery.extend({},options);var self=this,json={},push_counters={},patterns={"validate":/^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,"key":/[a-zA-Z0-9_]+|(?=\[\])/g,"push":/^$/,"fixed":/^\d+$/,"named":/^[a-zA-Z0-9_]+$/};this.build=function(base,key,value){base[key]=value;return base;};this.push_counter=function(key){if(push_counters[key]===undefined){push_counters[key]=0;} return push_counters[key]++;};jQuery.each(jQuery(this).serializeArray(),function(){if(!patterns.validate.test(this.name)){return;} var k,keys=this.name.match(patterns.key),merge=this.value,reverse_key=this.name;while((k=keys.pop())!==undefined){reverse_key=reverse_key.replace(new RegExp("\\["+k+"\\]$"),'');if(k.match(patterns.push)){merge=self.build([],self.push_counter(reverse_key),merge);} else if(k.match(patterns.fixed)){merge=self.build([],k,merge);} else if(k.match(patterns.named)){merge=self.build({},k,merge);}} json=jQuery.extend(true,json,merge);});return json;}})(jQuery);;if(typeof Object.keys!='function'){Object.keys=function(obj){if(typeof obj!='object'){obj=library.toObject(obj);} var ret=[];for(var x in obj){if(obj.hasOwnProperty(x)){ret[ret.length]=x;}} return ret;}} var library={camelCaseToTitleCase:function(in_camelCaseString){var result=in_camelCaseString.replace(/([a-z])([A-Z][a-z])/g,"$1 $2").replace(/([A-Z][a-z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z]+[a-z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z][a-z])/g,"$1 $2").replace(/([a-z]+)([A-Z0-9]+)/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-rt-z][a-z]*)/g,"$1 $2").replace(/([0-9])([A-Z][a-z]+)/g,"$1 $2").replace(/([A-Z]+)([0-9]+)/g,"$1 $2").replace(/([0-9]+)([A-Z]+)/g,"$1 $2").trim();return result.charAt(0).toUpperCase()+result.slice(1);},chunk:function(obj,size){var a=[] var b=[] $.each(obj,function(key,value){a.push(value);});for(var i=0;i
'+$.trim(output)+'':'');},extractTextWithWhitespace:function(elems){var lineBreakNodeName="BR";if($.browser.webkit){lineBreakNodeName="DIV";}else if($.browser.msie){lineBreakNodeName="P";}else if($.browser.mozilla){lineBreakNodeName="BR";}else if($.browser.opera){lineBreakNodeName="P";} var extractedText=extractTextWithWhitespaceWorker(elems,lineBreakNodeName);return extractedText;},extractTextWithWhitespaceWorker:function(elems,lineBreakNodeName){var ret="";var elem;for(var i=0;elems[i];i++){elem=elems[i];if(elem.nodeType===3||elem.nodeType===4){ret+=elem.nodeValue;} if(elem.nodeName===lineBreakNodeName){ret+="\n";} if(elem.nodeType!==8){ret+=library.extractTextWithWhitespace(elem.childNodes,lineBreakNodeName);}} return ret;},getCookie:function(c_name){var c_value=" "+document.cookie;var c_start=c_value.indexOf(" "+c_name+"=");if(c_start==-1){c_value=null;}else{c_start=c_value.indexOf("=",c_start)+1;var c_end=c_value.indexOf(";",c_start);if(c_end==-1){c_end=c_value.length;} c_value=unescape(c_value.substring(c_start,c_end));} return c_value;},getQueryVariable:function(variable){var query=window.location.search.substring(1);var vars=query.split("&");for(var i=0;i
';} if(this.options.images){html+=' | Image | ';} var c=0;$.each(that.options.fields,function(key,value){if($.inArray(value,that.options.exclude)==-1){if(value=='index'){html+=''+library.key(value)+' | ';}else{html+=''+library.key(value)+' | ';}} c++;});html+='
---|---|---|---|
';} if(that.options.images){html+=' | ';} $.each(obj,function(key,value){if($.inArray(key,that.options.fields)!==-1){if($.inArray(key,that.options.exclude)==-1){html+=' | '+value+' | ';}}});html+='